package com.ruoyi.rocky.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.rocky.domain.PcUser;
import com.ruoyi.rocky.domain.PcUserUpdateBaseInfo;
import com.ruoyi.rocky.service.PcUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/pcUser")
@Api(value = "UserController", tags = "用户管理")
public class PcUserController {

   @Autowired
   private PcUserService pcUserService;

   /**
    * 查询所有用户
    * @return
    */
   @ApiOperation(value = "查询所有用户")
   @GetMapping("/selAllUser")
   public R<List<PcUser>> selAllUser() {
      R<List<PcUser>> user = pcUserService.findAll();
      return user;
   }

   /**
    * 修改用户
    * @param user
    * @return
    */
   @ApiOperation(value = "修改用户")
   @PutMapping("/updateUser")
   public R<Boolean> updateUser(@RequestBody PcUserUpdateBaseInfo user) {
      return pcUserService.updateUser(user);
   }

   /**
    * 根据id删除用户
    * @param id
    * @return
    */
   @ApiOperation(value = "删除用户")
   @DeleteMapping("/deleteUser/{id}")
   public R<Boolean> deleteUser(@PathVariable("id") Long id) {
      return pcUserService.deleteUser(id);
   }
}
